package com.task.utils;   
  
import java.util.Calendar;   
import java.util.TimerTask;   
  
import javax.servlet.ServletContext;   

import com.task.dao.TaskDao;

public class StatisticsTask extends TimerTask   
{   
  
    private TaskDao taskDao;
    private static boolean isRunning = false;   
    private ServletContext context = null;   
  
    public void setTaskDao(TaskDao taskDao) {
		this.taskDao = taskDao;
	}

	public StatisticsTask(ServletContext context)   
    {   
        this.context = context;   
    }   
       
    public void run()   
    {   
         
        if (!isRunning)    
        {                  
                isRunning = true;    
                context.log("开始执行指定任务");   
                   
                System.out.println("开始执行");
                   
                //指定任务执行结束   
                isRunning = false;   
                context.log("指定任务执行结束");                 
        }    
        else    
        {   
            context.log("上一次任务执行还未结束");   
        }   
       
    }   
    //需要执行的任务
    public void opeTask(){
    	taskDao.updateTaskToTomorrow();
    }
  
}  
